<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  

  
  <title>Huafeihua</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  
  
  <meta property="og:type" content="website">
<meta property="og:title" content="Huafeihua">
<meta property="og:url" content="http://malone00.gitee.io/huafeihua/page/3/index.html">
<meta property="og:site_name" content="Huafeihua">
<meta property="og:locale" content="zh-CN">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Huafeihua">
  
    <link rel="alternate" href="/huafeihua/atom.xml" title="Huafeihua" type="application/atom+xml">
  
  
    <link rel="icon" href="/images/tmp.jpg">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/huafeihua/css/style.css">
  <link rel="stylesheet" href="/huafeihua/css/highlight.css">
</head>
</html>
<body>
  <div id="fullpage" class="mobile-nav-right">
    
      <div id="wrapper" title="图片来自网络">
    
    
      <header id="header">
  <div id="nav-toggle" class="nav-toggle"></div>
  <div class="head-box global-width">
    <nav class="nav-box nav-right">
      
        <a class="nav-item" href="/huafeihua/" title="">首页</a>
      
        <a class="nav-item" href="/huafeihua/categories" title="">分类</a>
      
        <a class="nav-item" href="/huafeihua/archives" title="">归档</a>
      
        <a class="nav-item" href="/huafeihua/tags" title="">标签</a>
      
        <a class="nav-item" href="/huafeihua/about" title="">关于</a>
      
    </nav>
  </div>
</header>
      <div id="middlecontent" title class="global-width sidebar-left">
        <section id="main">
  
    <article id="post-python/python-写爬虫笔记" class="article global-container article-type-post" itemscope itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/python-写爬虫笔记/">Python-爬虫笔记</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/python-写爬虫笔记/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/爬虫/">爬虫</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        
<!DOCTYPE html>
<html lang="en">
  <head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>python 写爬虫笔记</title>
    <style type="text/css" media="all">
      body {
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", sans-serif;
        font-size: 14px;
        line-height: 20px;
        color: #777;
        background-color: white;
      }
      .container {
        width: 700px;
        margin-right: auto;
        margin-left: auto;
      }

      .post {
        font-family: Georgia, "Times New Roman", Times, "SimSun", serif;
        position: relative;
        padding: 70px;
        bottom: 0;
        overflow-y: auto;
        font-size: 16px;
        font-weight: normal;
        line-height: 25px;
        color: #515151;
      }

      .post h1{
        font-size: 50px;
        font-weight: 500;
        line-height: 60px;
        margin-bottom: 40px;
        color: inherit;
      }

      .post p {
        margin: 0 0 35px 0;
      }

      .post img {
        border: 1px solid #D9D9D9;
      }

      .post a {
        color: #28A1C5;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="post">
        <h1 class="title">python 写爬虫笔记</h1>
        <div class="show-content">
          <h1>估算网站大小</h1><p>site:example.com</p><p>site:example.com/view  查看收录情况</p><p><br></p><p>lxml</p><p>http : / / Lxml.de/installat i on . html<br></p>
        </div>
      </div>
    </div>
  </body>
</html>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/python--虚拟环境" class="article global-container article-type-post" itemscope itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/python--虚拟环境/">Python-虚拟环境</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/python--虚拟环境/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        
<!DOCTYPE html>
<html lang="en">
  <head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>python  虚拟环境</title>
    <style type="text/css" media="all">
      body {
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", sans-serif;
        font-size: 14px;
        line-height: 20px;
        color: #777;
        background-color: white;
      }
      .container {
        width: 700px;
        margin-right: auto;
        margin-left: auto;
      }

      .post {
        font-family: Georgia, "Times New Roman", Times, "SimSun", serif;
        position: relative;
        padding: 70px;
        bottom: 0;
        overflow-y: auto;
        font-size: 16px;
        font-weight: normal;
        line-height: 25px;
        color: #515151;
      }

      .post h1{
        font-size: 50px;
        font-weight: 500;
        line-height: 60px;
        margin-bottom: 40px;
        color: inherit;
      }

      .post p {
        margin: 0 0 35px 0;
      }

      .post img {
        border: 1px solid #D9D9D9;
      }

      .post a {
        color: #28A1C5;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="post">
        <h1 class="title">python  虚拟环境</h1>
        <div class="show-content">
          <p>工具：virtualenv:</p><p>查看版本 virtualenv --version</p><p>新建虚拟环境：virtualenv venv</p><hr><h3>激活环境：</h3><p>Linux ：source venv/bin/activate</p><p> Windows: venv\Scripts\activate<br></p>
        </div>
      </div>
    </div>
  </body>
</html>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/Python-连接mysql" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/Python-连接mysql/">Python-连接mysql</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/Python-连接mysql/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <div class="highlight-box" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true" data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">from pymysql import *  # 导入</span><br><span class="line">def main():</span><br><span class="line">    conn = connect(host=&apos;&apos;, port=, user=&apos;&apos;, password=&apos;&apos;, database=&apos;&apos;, charset=&apos;utf8)</span><br><span class="line">    cs1 = conn.cursor()</span><br><span class="line">    count = cs1.execute(&apos;sql&apos;)    # 创建命令 conn.commit()</span><br><span class="line">    print(&apos;查询到%d数据：&apos; % count)</span><br><span class="line">    for i in range(count):</span><br><span class="line">        result = cs1.fetchone() #cs1.fetchall()</span><br><span class="line">        print(result)</span><br><span class="line">    cs1.close()</span><br><span class="line">    conn.close()</span><br></pre></td></tr></table></figure></div>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-about" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/about/">&#39;about&#39;</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/about/" class="article-date">
  <time datetime="2019-01-22T09:10:27.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
    
  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <h1 id="关于本人"><a href="#关于本人" class="headerlink" title="关于本人"></a>关于本人</h1><h3 id="这就是一个博客"><a href="#这就是一个博客" class="headerlink" title="这就是一个博客"></a>这就是一个博客</h3><p>不断努力奋斗的小强！</p>
<blockquote>
<p>路在何方，路在脚下</p>
</blockquote>
<p>一个小博客！<br><br>QQ：1423808921</p>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-flask/WTForms验证函数" class="article global-container article-type-post" itemscope itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/flask/WTForms验证函数/">flask-WTForms验证函数</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/flask/WTForms验证函数/" class="article-date">
  <time datetime="2019-01-22T08:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/flask/">flask</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        
<!DOCTYPE html>
<html lang="en">
  <head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WTForms验证函数</title>
    <style type="text/css" media="all">
      body {
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", sans-serif;
        font-size: 14px;
        line-height: 20px;
        color: #777;
        background-color: white;
      }
      .container {
        width: 700px;
        margin-right: auto;
        margin-left: auto;
      }

      .post {
        font-family: Georgia, "Times New Roman", Times, "SimSun", serif;
        position: relative;
        padding: 70px;
        bottom: 0;
        overflow-y: auto;
        font-size: 16px;
        font-weight: normal;
        line-height: 25px;
        color: #515151;
      }

      .post h1{
        font-size: 50px;
        font-weight: 500;
        line-height: 60px;
        margin-bottom: 40px;
        color: inherit;
      }

      .post p {
        margin: 0 0 35px 0;
      }

      .post img {
        border: 1px solid #D9D9D9;
      }

      .post a {
        color: #28A1C5;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="post">
        <h1 class="title">WTForms验证函数</h1>
        <div class="show-content">
          <p>表4-2 WTForms验证函数<br></p><p>验证函数 说　　明</p><p>Email验证电子邮件地址</p><p>EqualTo比较两个字段的值；常用于要求输入两次密码进行确认的情况</p><p>IPAddress验证IPv4网络地址</p><p>Length验证输入字符串的长度</p><p>NumberRange验证输入的值在数字范围内</p><p>Optional无输入值时跳过其他验证函数</p><p>Required确保字段中有数据</p><p>Regexp使用正则表达式验证输入值</p><p>URL验证URL</p><p>AnyOf确保输入值在可选值列表中</p><p>NoneOf确保输入值不在可选值列表中</p>
        </div>
      </div>
    </div>
  </body>
</html>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/Python-Alchemy使用" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/Python-Alchemy使用/">Python-Alchemy使用</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/Python-Alchemy使用/" class="article-date">
  <time datetime="2019-01-22T08:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <div class="highlight-box" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true" data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><span class="line">#-*- coding:UTF-8 -*-</span><br><span class="line"></span><br><span class="line">#导入类</span><br><span class="line">from sqlalchemy import Column,Table ,String, create_engine,MetaData</span><br><span class="line">from sqlalchemy.orm import sessionmaker, relationship</span><br><span class="line">from sqlalchemy import create_engine</span><br><span class="line">from sqlalchemy.ext.declarative import declarative_base</span><br><span class="line">from sqlalchemy.sql.schema import ForeignKey</span><br><span class="line">from random import randint</span><br><span class="line"></span><br><span class="line">#创建对象的基类：</span><br><span class="line">BASE = declarative_base()</span><br><span class="line">engine = create_engine(&apos;sqlite:///test.db&apos;) </span><br><span class="line"></span><br><span class="line">#创建表</span><br><span class="line">def init_db():</span><br><span class="line">    BASE.metadata.create_all(engine)</span><br><span class="line"></span><br><span class="line">#删除表</span><br><span class="line">def drop_db():</span><br><span class="line">    BASE.metadata.drop_all(engine)</span><br><span class="line">    </span><br><span class="line">class User(BASE):</span><br><span class="line">    __tablename__ = &apos;users&apos;</span><br><span class="line">    </span><br><span class="line">    id = Column(String(20), primary_key=True)</span><br><span class="line">    name = Column(String(20))</span><br><span class="line">    password = Column(String(124))</span><br><span class="line">    </span><br><span class="line">    #一对多 一个用户有多个书</span><br><span class="line">    books = relationship(&apos;Book&apos;)</span><br><span class="line">    </span><br><span class="line">class Book(BASE):</span><br><span class="line">    __tablename__ = &apos;book&apos;</span><br><span class="line">    id = Column(String(20),primary_key=True)</span><br><span class="line">    name = Column(String(100))</span><br><span class="line">    </span><br><span class="line">    #“多”的一方，通过外键关联到user表的</span><br><span class="line">    user_id = Column(String(20),ForeignKey(&apos;users.id&apos;))</span><br><span class="line">    </span><br><span class="line"> </span><br><span class="line">Session = sessionmaker(bind=engine, autocommit=False, autoflush=False)</span><br><span class="line">session = Session()</span><br><span class="line"></span><br><span class="line">#初始化</span><br><span class="line">init_db()</span><br><span class="line"></span><br><span class="line">#查询功能</span><br><span class="line">#user = session.query(User).filter(User.id==&apos;5&apos;).one()</span><br><span class="line">user = session.query(User)</span><br><span class="line">for i in user:</span><br><span class="line">    print i.name</span><br><span class="line"></span><br><span class="line">books = session.query(Book)</span><br><span class="line">for b in books:</span><br><span class="line">    print b.name</span><br><span class="line"></span><br><span class="line">#批量插入数据    </span><br><span class="line">session.execute(</span><br><span class="line">    User.__table__.insert(),</span><br><span class="line">    [&#123;&apos;id&apos;:i,&apos;name&apos;:randint(1,100),&apos;password&apos;:randint(1,100)&#125; for i in xrange(7,100)]                 </span><br><span class="line">                )    </span><br><span class="line">session.commit()  #提交</span><br><span class="line">#增加功能</span><br><span class="line">#添加人</span><br><span class="line">#user = User(id=&apos;6&apos;,name=&apos;Lucy&apos;,password=&apos;lucy&apos;)</span><br><span class="line">#添加书</span><br><span class="line">#user = Book(id=&apos;2&apos;,name=u&apos;Python大法&apos;,user_id=&apos;5&apos;)</span><br><span class="line"></span><br><span class="line">#session.add(user)</span><br><span class="line">#session.commit()</span><br><span class="line">session.close_all()</span><br><span class="line">print &quot;OK&quot;</span><br></pre></td></tr></table></figure></div>
<p>—–END—-</p>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-flask/请求钩子" class="article global-container article-type-post" itemscope itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/flask/请求钩子/">flask-请求钩子</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/flask/请求钩子/" class="article-date">
  <time datetime="2019-01-22T08:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/flask/">flask</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        
<!DOCTYPE html>
<html lang="en">
  <head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>请求钩子</title>
    <style type="text/css" media="all">
      body {
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", sans-serif;
        font-size: 14px;
        line-height: 20px;
        color: #777;
        background-color: white;
      }
      .container {
        width: 700px;
        margin-right: auto;
        margin-left: auto;
      }

      .post {
        font-family: Georgia, "Times New Roman", Times, "SimSun", serif;
        position: relative;
        padding: 70px;
        bottom: 0;
        overflow-y: auto;
        font-size: 16px;
        font-weight: normal;
        line-height: 25px;
        color: #515151;
      }

      .post h1{
        font-size: 50px;
        font-weight: 500;
        line-height: 60px;
        margin-bottom: 40px;
        color: inherit;
      }

      .post p {
        margin: 0 0 35px 0;
      }

      .post img {
        border: 1px solid #D9D9D9;
      }

      .post a {
        color: #28A1C5;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="post">
        <h1 class="title">请求钩子</h1>
        <div class="show-content">
          <p>before_first_request：注册一个函数，在处理第一个请求之前运行。</p><p>before_request：注册一个函数，在每次请求之前运行。</p><p>after_request：注册一个函数，如果没有未处理的异常抛出，在每次请求之后运行。</p><p>teardown_request：注册一个函数，即使有未处理的异常抛出，也在每次请求之后运行。</p><hr><p>在请求钩子函数和视图函数之间共享数据一般使用上下文全局变量g。例如，before_<br></p><p>request处理程序可以从数据库中加载已登录用户，并将其保存到g.user中。随后调用视</p><p>图函数时，视图函数再使用g.user获取用户。</p>
        </div>
      </div>
    </div>
  </body>
</html>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/Python-操作Oracle" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/Python-操作Oracle/">Python-操作Oracle</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/Python-操作Oracle/" class="article-date">
  <time datetime="2019-01-22T08:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <p>1.环境<br>Anaconda<br>python 2.7<br>windows 10<br>instantclient_11_2<br>!!!注意 32位和64位区别</p>
<ol start="2">
<li>安装<br>pip install cx_Oracle</li>
</ol>
<div class="highlight-box" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true" data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">import cx_Oracle</span><br><span class="line">conn = cx_Oracle(&apos;username&apos;,&apos;pwd&apos;,&apos;10.10.10.10:1521/health&apos;)</span><br><span class="line">#the same as    conn = cx_Oracle(&apos;username/pwd@10.10.10.10/health&apos;)</span><br><span class="line">c = conn.cursor()</span><br><span class="line">f = c.execute(&quot;&quot;&quot; sql语句 &quot;&quot;&quot;)</span><br><span class="line">f.fetchone() #显示一条结果</span><br><span class="line">c.close()</span><br><span class="line">c = conn.cursor()</span><br><span class="line">c.prepare(&quot;&quot;&quot; select * from tablename where id = :id &quot;&quot;&quot;)</span><br><span class="line">f = c.execute(None,&#123;&apos;id&apos;:&apos;001&apos;&#125;)</span><br><span class="line">#conn.close()</span><br></pre></td></tr></table></figure></div>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/Anaconda2切换python版本2018-04-20" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/Anaconda2切换python版本2018-04-20/">Anaconda2切换python版本</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/Anaconda2切换python版本2018-04-20/" class="article-date">
  <time datetime="2019-01-22T08:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <p>1.安装Anaconda2<br><a href="https://www.anaconda.com/download/" target="_blank" rel="noopener">点我下载 </a><br>2.默认安装2.7<br>3.打开Navigater-左侧选择Environments<br>4.下面Create 按钮 选择环境名称和py版 这里选择3.6 名称为test</p>
<p>命令行conda info –envs</p>
<p>切换环境：<br>activate test</p>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-flask/响应方式-重定向，处理错误abort" class="article global-container article-type-post" itemscope itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/flask/响应方式-重定向，处理错误abort/">flask-响应方式-响应方式 重定向，处理错误abort</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/flask/响应方式-重定向，处理错误abort/" class="article-date">
  <time datetime="2019-01-22T08:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/flask/">flask</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        
<!DOCTYPE html>
<html lang="en">
  <head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>响应方式 重定向，处理错误abort</title>
    <style type="text/css" media="all">
      body {
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", sans-serif;
        font-size: 14px;
        line-height: 20px;
        color: #777;
        background-color: white;
      }
      .container {
        width: 700px;
        margin-right: auto;
        margin-left: auto;
      }

      .post {
        font-family: Georgia, "Times New Roman", Times, "SimSun", serif;
        position: relative;
        padding: 70px;
        bottom: 0;
        overflow-y: auto;
        font-size: 16px;
        font-weight: normal;
        line-height: 25px;
        color: #515151;
      }

      .post h1{
        font-size: 50px;
        font-weight: 500;
        line-height: 60px;
        margin-bottom: 40px;
        color: inherit;
      }

      .post p {
        margin: 0 0 35px 0;
      }

      .post img {
        border: 1px solid #D9D9D9;
      }

      .post a {
        color: #28A1C5;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="post">
        <h1 class="title">响应方式 重定向，处理错误abort</h1>
        <div class="show-content">
          <p>重定向经常使用302状态码表示，指向的地址由Location首部提供。重定向响应可以使用<br></p><p>3个值形式的返回值生成， 也可在Response对象中设定。不过，由于使用频繁，Flask提</p><p>供了redirect()辅助函数，用于生成这种响应：</p><p>from flask import redirect</p><p>@app.route('/')</p><p>def index():</p><p>return redirect('http://www.example.com')</p><p>还有一种特殊的响应由abort函数生成，用于处理错误。在下面这个例子中，如果URL中</p><p>动态参数id对应的用户不存在，就返回状态码404：</p><p>from flask import abort</p><p>@app.route('/user/')</p><p>def get_user(id):</p><p>user = load_user(id)</p><p>if not user:</p><p>abort(404)</p><p>return '</p><h1>Hello,%s</h1>'%user.name<p></p><p>注意，abort不会把控制权交还给调用它的函数，而是抛出异常把控制权交给Web服</p><p>务器。</p>
        </div>
      </div>
    </div>
  </body>
</html>

      
    </div>
    
  </div>
  
  
</article>

  


  <nav id="page-nav">
    
    <a class="extend prev" rel="prev" href="/huafeihua/page/2/">&laquo; 上一页</a><a class="page-number" href="/huafeihua/">1</a><a class="page-number" href="/huafeihua/page/2/">2</a><span class="page-number current">3</span><a class="page-number" href="/huafeihua/page/4/">4</a><a class="page-number" href="/huafeihua/page/5/">5</a><a class="page-number" href="/huafeihua/page/6/">6</a><a class="extend next" rel="next" href="/huafeihua/page/4/">下一页 &raquo;</a>
  </nav>


</section>
        <aside id="sidebar">
  
    <div class="widget-box">
  <div class="avatar-box">
    <img class="avatar" src="/huafeihua/images/default-avatar.jpeg" title="图片来自网络">
    <h3 class="avatar-name">
      
        听风看雨
      
    </h3>
    <p class="avatar-slogan">
      抗揍的愤青，半个IT男。
    </p>
  </div>
</div>


  
    
  <div class="widget-box">
    <h3 class="widget-title">分类</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/Linux/">Linux</a></li><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/python/">python</a></li><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/入坑/">入坑</a></li><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/技巧/">技巧</a></li><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/自动化/">自动化</a></li><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/项目管理/">项目管理</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-box">
    <h3 class="widget-title">标签</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Appium/">Appium</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Docker/">Docker</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Jenkins/">Jenkins</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Nginx/">Nginx</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Selenium/">Selenium</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Ubuntu/">Ubuntu</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/centos/">centos</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/flask/">flask</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/python/">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/rabbit/">rabbit</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/sql/">sql</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/ubuntu/">ubuntu</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/效率/">效率</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/爬虫/">爬虫</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-box">
    <h3 class="widget-title">标签云</h3>
    <div class="widget tagcloud">
      <a href="/huafeihua/tags/Appium/" style="font-size: 10px;">Appium</a> <a href="/huafeihua/tags/Docker/" style="font-size: 13.33px;">Docker</a> <a href="/huafeihua/tags/Jenkins/" style="font-size: 10px;">Jenkins</a> <a href="/huafeihua/tags/Nginx/" style="font-size: 10px;">Nginx</a> <a href="/huafeihua/tags/Selenium/" style="font-size: 13.33px;">Selenium</a> <a href="/huafeihua/tags/Ubuntu/" style="font-size: 10px;">Ubuntu</a> <a href="/huafeihua/tags/centos/" style="font-size: 16.67px;">centos</a> <a href="/huafeihua/tags/flask/" style="font-size: 20px;">flask</a> <a href="/huafeihua/tags/python/" style="font-size: 20px;">python</a> <a href="/huafeihua/tags/rabbit/" style="font-size: 10px;">rabbit</a> <a href="/huafeihua/tags/sql/" style="font-size: 10px;">sql</a> <a href="/huafeihua/tags/ubuntu/" style="font-size: 10px;">ubuntu</a> <a href="/huafeihua/tags/效率/" style="font-size: 10px;">效率</a> <a href="/huafeihua/tags/爬虫/" style="font-size: 10px;">爬虫</a>
    </div>
  </div>

  
    
  <div class="widget-box">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/huafeihua/archives/2019/01/">一月 2019</a></li></ul>
    </div>
  </div>

  
    
  <div class="widget-box">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/huafeihua/2019/01/29/python-mq/">python rabbitmq</a>
          </li>
        
          <li>
            <a href="/huafeihua/2019/01/22/python/Unittest/">Python-Unittest</a>
          </li>
        
          <li>
            <a href="/huafeihua/2019/01/22/项目管理/项目管理2018-07-23/">U项目管理</a>
          </li>
        
          <li>
            <a href="/huafeihua/2019/01/22/随笔/-Kanboard-安装之Windows/">Kanboard 安装之Windows</a>
          </li>
        
          <li>
            <a href="/huafeihua/2019/01/22/运维部署/单网卡实现内外网访问/">单网卡实现内外网访问</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
      </div>
      <footer id="footer">
  <div class="foot-box global-width">
    &copy; 2019 Edwin Ma &nbsp;&nbsp;
    驱动于 <a href="http://hexo.io/" target="_blank">Hexo</a><br>
    <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span id="busuanzi_container_site_pv">阁下是第<span id="busuanzi_value_site_pv"></span>个访客</span>
  </div>
</footer>
      <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

<script src="/js/jquery-2.0.3.min.js"></script>

  <link rel="stylesheet" href="/huafeihua/fancybox/jquery.fancybox.css">
  <script src="/huafeihua/fancybox/jquery.fancybox.pack.js"></script>


<script src="/huafeihua/js/script.js"></script>



    </div>
    <nav id="mobile-nav" class="mobile-nav-box">
  <div class="mobile-nav-img mobile-nav-top"></div>
  
    <a href="/huafeihua/" class="mobile-nav-link">首页</a>
  
    <a href="/huafeihua/categories" class="mobile-nav-link">分类</a>
  
    <a href="/huafeihua/archives" class="mobile-nav-link">归档</a>
  
    <a href="/huafeihua/tags" class="mobile-nav-link">标签</a>
  
    <a href="/huafeihua/about" class="mobile-nav-link">关于</a>
  
  <div class="mobile-nav-img  mobile-nav-bottom"></div>
</nav>    
  </div>
</body>
</html>